package com.tianruan.dc.modules.sys.user.mapper;


import org.apache.ibatis.annotations.*;

public interface SmsCodeMapper {

    @Mapper


    /**
     *  插入验证码
     * @param phone
     * @param smsCode
     * @return
     */
    @Insert("INSERT INTO t_ipa_sms_log (phone, sms_code, send_time) VALUES (#{phone}, #{smsCode}, NOW()) ON DUPLICATE KEY UPDATE sms_code = #{smsCode}, send_time = NOW()")
    void insertSmsLog(@Param("phone") String phoneNumber, @Param("smsCode") String smsCode);

    /**查询手机号
     *
     * @param phone
     * @return
     */
    @Select("SELECT sms_code FROM t_ipa_sms_log WHERE phone = #{phone}")
    String selectSmsCode(@Param("phone") String phone);

    /**更新手机号
     *
     * @param  id
     * @param phone
     */
    @Update("UPDATE t_sys_user SET phone = #{phone} WHERE id = #{id}")
    void updatePhoneNumberById(@Param("id") String id, @Param("phone") String phone);

    @Select("SELECT * FROM t_sys_user WHERE id = #{id}")
    String selectById(String id);
}

